#!/usr/bin/env python
#coding=utf-8
import threading,time

def thread_work(list_work=[]):
	""" """
	global lock
	lock.acquire()
	list_work.append('a')
	print threading.currentThread().getName(), len(list_work)
	lock.release()
	time.sleep(3)


lock = threading.Lock()

def test(num=0):
	list_thread = []
	list_work = []
	for i in xrange(num):
		t = threading.Thread(target=thread_work,args=[list_work])
		list_thread.append(t)

	for t in list_thread:
		t.start()

	for t in list_thread:
		t.join()

if __name__ == '__main__':
	test(500)